    /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Toinamph
 */
public class SemanticQualification {
    static public int idLastCreated = 0;
    
    private int id;
    private Form formConcerned;
    private List<FormalConcept> formalConcepts = new ArrayList<FormalConcept>();
    
    public SemanticQualification() {
        this.id = Commun.IncrementId(idLastCreated,1);
        idLastCreated++;
    }
    
    public SemanticQualification(Form f) {
        this();
        formConcerned = f;
    }

    public Form getFormConcerned() {
        return formConcerned;
    }

    public void setFormConcerned(Form formConcerned) {
        this.formConcerned = formConcerned;
    }
    
    public int checkFormalConcept(FormalConcept fc) {
        if(formalConcepts.contains(fc)) {
            return -1;
        } else {
            return 0;
        }
    }
    
    public int addFormalConcept(FormalConcept fc) {
        if(checkFormalConcept(fc) == -1) {
            return -1;
        }
        formalConcepts.add(fc);
        return 0;
    }
    
    public int deleteFormalConcept(FormalConcept fc){
        if(checkFormalConcept(fc) == -1) {
            return -1;
        }
        formalConcepts.remove(fc);
        return 0;
    }
 
    public int getId() {
        return id;
    }

    public List<FormalConcept> getFormalConcepts() {
        return formalConcepts;
    }

    public void setFormalConcepts(List<FormalConcept> formalConcepts) {
        this.formalConcepts = formalConcepts;
    }
    
    public int findFormalConcept(String fcName){
        int ret = -1;
        Boolean find = false;
        int i = 0;
        while ((find==false) && (i<formalConcepts.size())){
            if (formalConcepts.get(i).getName() == fcName){
                find = true;
                ret = i;
            } else {
                i++;
            }
        }
        return ret;
    }
}
